<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>CKEDITOR.htmlParser</title>
	<link rel="stylesheet" type="text/css" href="../../test.css" />
	<script type="text/javascript" src="../../../ckeditor.js"></script>
	<script type="text/javascript" src="../../test.js"></script>
	<script type="text/javascript">
	//<![CDATA[

CKEDITOR.plugins.load( 'htmlwriter' );
var tc;
CKEDITOR.test.addTestCase( tc = ( function()
{
	// Local reference to the "assert" object.
	var assert = YAHOO.util.Assert;

	/**
	 * Wrapper of the combination of htmlParser with htmlWriter, for convenience of
	 * testing, formatting of writer has been disabled.
	 */
	function htmlParse( htmlString , writerConfig)
	{
		var writer = new CKEDITOR.htmlParser.basicWriter();
		writer.reset();
		var fragment = CKEDITOR.htmlParser.fragment.fromHtml( htmlString );
		fragment.writeHtml( writer );
		return writer.getHtml();
	}

	/**
	 * IE always returning CRLF for line-feed, so remove it when retrieving
	 * pre-formated text from text area.
	 */
	function getTextAreaValue( id )
	{
		return CKEDITOR.document.getById( id ).getValue().replace( /\r/gi, '' );
	}

	return {
		/**
		 * Test <pre> tag formatting.
		 */
		test_fromHtml_3715 : function()
		{
			assert.areSame( getTextAreaValue( 'htmlResult1' ),
				htmlParse( getTextAreaValue( 'htmlOriginal1' ) ),
				'<pre> parsing result doesn\'t match.' );
		},

		/**
		 * Test compress empty spaces within text.
		 */
		test_fromHtml_3715_2 : function()
		{
			assert.areSame( getTextAreaValue( 'htmlResult2' ),
				htmlParse( getTextAreaValue( 'htmlOriginal2' ) ),
				'Spaces compressing result doesn\'t match.' );
		},
		name :document.title
	};
} )() );

//window.onload = tc.test_fromHtml_3715;
	//]]>
	</script>
</head>
<body>

	<textarea id="htmlOriginal1"><pre>
	text<b>
inside<br /><br /></b>

pre
</pre></textarea>
	<textarea id="htmlResult1"><pre>
	text<b>
inside

</b>

pre
</pre></textarea>

<textarea id="htmlOriginal2"><p>
	para		graph
</p><b>compress   spaces</b></textarea>

<textarea id="htmlResult2"><p>para graph</p><b>compress spaces</b></textarea>
</body>
</html>
